-
Notifications
You must be signed in to change notification settings - Fork 280
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix AnsiOutput
write methods claiming zero bytes were written
#31
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
write!(handle, "{}", string)?; | ||
handle.flush(); | ||
Ok(0) | ||
let out = &self.handle; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For some reason there are 5 spaces instead of 4 now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no, the line 16 has only 3 spaces so it looks like 5.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for reviewing! You are right jojolepro I see that all functions are one space outlined. I'll clean it up.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sorry about that, the original function was missing one space of indentation, so I tried to fix it, but I think I missed line 16. My bad.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't worry already fixed it! But thanks for your pull request!
Thanks, my fault :( ! I'll merge it an do a release. I have on question could the release wait for a couple of days? This because there maybe come another PR so I could have two patches in one release. If that doesn't work out let me know! You could then use the GitHub repo with master branch in your cargo.toml |
I published the new version 4.2 with the changes! |
Currently, the implementation of
IStdout
forAnsiOutput
always returnsOk(0)
when a write completes successfully.This behaviour is incorrect, as these methods are used elsewhere to implement
std::io::Write
, which expects the writer to return the number of bytes written. This means that the implementation ofWrite
forcrossterm::Terminal
doesn't play nice with thewrite!
macro (and other consumers of theWrite
trait), causing uses ofwrite!
to panic with the message "failed to write whole buffer". (see mgattozzi/ysh#12).This branch changes these methods to correctly return the number of bytes written, fixing the panics.